package com.gyh.modules.test;

import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;

import com.gyh.system.gen.utils.VelocityUtils;

/**
* @author 作者 gyh:
* @version 创建时间：2018年1月7日 下午7:59:36
* 
*/
public class AppTest22 {

	public static void main(String[] args) {
		
		Template t = VelocityUtils.getTemplate("template/velocity/Hellovelocity.vm");

		VelocityContext ctx = new VelocityContext();
		
		ctx.put("name", "velocity");
		ctx.put("date", (new Date()).toString());
		
		List<entityss> attrs = new ArrayList<>();
		attrs.add(new entityss("key1", "asdfsdf"));
		attrs.add(new entityss("key2", "asdfsdf"));
		attrs.add(new entityss("key3", "asdfsdf"));
		 
		ctx.put("attrs", attrs);
		 
		StringWriter sw = new StringWriter();
		t.setEncoding("UTF-8");
		t.merge(ctx, sw);
		  
		System.out.println(sw.toString());
	}
}
